define(['config/appregister', "jquery"], function(app) {
	app.controller("touristCtrl", function($scope, $state) {
		var ip = "http://"+allUrl+":8080";
		var u = "/elink_user/api/person/getBasePersonInfoByOther";

		var userid = "66248b206ad241039c9429dddd616ec3";
		render();

		function render() {
			$.ajax({
				type: "get",
				url: ip + u + "?otherUserId=" + userid,
				xhrFields: {
					withCredentials: true
				},
				crossDomain: true,
				success: function(data) {
					if(data.code == 0) {
						$scope.lvname = data.data.levelName;
						$scope.name = data.data.nickname;
						$scope.pic = data.data.logo;
						$scope.zy = data.data.databaseSecondName;
						$scope.fs = data.data.byFollowCount;
						$scope.gz = data.data.followCount;
						$scope.rq = data.data.browseCount;
						$scope.jj = data.data.introduction;
						$scope.switchval = data.data.isFollow;
						if($scope.switchval == 1) {
							$(".isfollow").html("取消关注").css("background", "#ffa30c url(" + "them/img/isfollow.png" + ") 4px 5px no-repeat");
						} else if($scope.switchval == 0) {
							$(".isfollow").html("关注").css({
								"width": "30px",
								"background": "#ffa30c",
								"padding-left": "6px"
							});
						} else {
							console.log("isfollow有问题");
						}
					} else {
						console.log(data.msg)
					}
				},
				error: function() {
					console.log("获取别人顶部个人信息请求失败")
				}
			});
		};

		//关闭弹出
		$scope.offbomb = function() {
				$(".bomb-box").hide();
			}
			//打开弹出
		$scope.openbomb = function() {
				$(".bomb-box").show();
			}
			//发送消息
		$scope.domsg = function() {
			var content = $(".bomb-box-3").val();
			var id = "66248b206ad241039c9429dddd616ec3";
			var msgurl = "/elink_user/api/message/addMessage";
			if(content !== "" && id !== "") {
				$.ajax({
					type: "post",
					url: ip + msgurl,
					xhrFields: {
						withCredentials: true
					},
					crossDomain: true,
					data: {
						byUserId: id,
						content: content
					},
					success: function(data) {
						if(data.code == 0) {
							console.log("发送消息成功")
							$(".bomb-box2").show();
							$(".bomb-box").hide();
						} else {
							console.log(data.msg);
						}
					},
					error: function() {
						console.log("发送消息请求失败")
					}
				});
			} else {
				console.log("有空参数");
			}

		}

	})
})